<?php
/**
 * VDONG Project
 * ============================================================================
 * Copyright (c) 2016 www.vdchina.com
 * ----------------------------------------------------------------------------
 * 文件名称：index.php
 * ----------------------------------------------------------------------------
 * 功能描述：获取轮播图
 * ----------------------------------------------------------------------------
 * 作者：liyinglong
 * ----------------------------------------------------------------------------
 */
namespace app\banner\home;
use think\Db;
// use app\base\controller\Base;
// use app\banner\model\HomeBanner;
use app\common;

class Lists 
{
    
  
        /**
        *获取轮播图列表
        *@param    int $projectid      商户id
        *@param    int $page_number    页码
        *@param    int $page_size      页面大小
        *@return   int $advlist        轮播图数据   Array ( [0] => Array ( [id] => 1 [title] => juxjua [url] => http:// ) )
        */ 
        public function getBannerList()
        {    

               if(empty($_POST['projectid'])){
                   outFormat(1,'商品ID不存在');
               }

               $where['projectid'] = intval($_POST['projectid']);//前端传过来的商家projectid
               $where['status'] = 0 ;       //状态  0代表显示  1代表不显示
               $page_number        = intval($_POST['page_number']);  //页码
               $page_size          = intval($_POST['page_size']);   //页面大小
             
               $field   = 'projectid,title,url';   //所需查询字段
               $order   = 'id desc';        //排序方式
               
                //获取数据
                $advlist = getByWhereList('banner_banner',$where,$field,$order,$page_number,$page_size);
               //过滤查询数据的对象，只留下数组
                $advlistData = collection($advlist)->toArray();
                
                //获取数据总的条数
                $advlistCount = getByWhereCount('banner_banner',$where,$field,$order);

                if(!empty($advlistData)){
                        //返还数据   1 代表有数据返回 
                       outFormats($advlistData,'success',1,$page_number,$advlistCount,0);
                }else{
                       //0代表没有数据返还
                        outFormats($advlistData,'error',0,$page_number,$advlistCount,1);
                }
                             
         }



}//类的结束符
